<?php
session_start();
echo "var curDB='".$_SESSION["selDB"]."';";
?>
function unMask() {
		Ext.getCmp('mainPanel').doLayout();
	}
function openTab(vAttr) {
	myPanel = Ext.getCmp('mainPanel');
	myPanel.removeAll(true);
	myPanel.load({
	url: "/" + vAttr.page,
		scripts: true,
		callback: unMask
	});
	myPanel.setTitle (vAttr.text, vAttr.iconCls);
	}

  function addTab(tabTitle, targetUrl,closable,icon,tabId){
        var tabPanel = Ext.getCmp('mainPanel');
        tabPanel.add({
	    title: tabTitle,
            id:tabId,
	    iconCls: icon,
	    autoLoad: {url: targetUrl, callback: this.initSearch, scope: this,scripts:true},
      autoScroll :true,
	    closable:closable
	}).show();
    }

    // Update the contents of a tab if it exists, otherwise create a new one
    function updateTab(tabId,title, url) {
    var tabPanel = Ext.getCmp('mainPanel');
    	var tab = tabPanel.getItem(tabId);
    	if(tab){
    		tab.getUpdater().update(url);
    		tab.setTitle(title);
    	}else{
    		tab = addTab(title,url);
    	}
    	tabPanel.setActiveTab(tab);
    }


Ext.onReady(function(){
 var viewport = new Ext.Viewport({
            layout: 'border',
            items: [
            // create instance immediately
            new Ext.BoxComponent({
                region: 'north',
                contentEl : 'north',
		height: 36
               

            }),
			{
                region: 'west',
                id: 'west-panel', // see Ext.getCmp() below
                title: "Main",
                split: true,
                width: 213,
                minSize: 175,
                maxSize: 400,
                collapsible: true,
                margins: '0 0 0 5',
                autoLoad: {url: "/source/main_tree/tree.php", scope: this,scripts:true},
            },
             new Ext.TabPanel({
		region:'center',
                id:'mainPanel',
		deferredRender:false,
		autoScroll: true,
		margins:'0 4 4 0',
		activeTab:0
		
    }),
             new Ext.BoxComponent({
                region: 'south',
                contentEl : 'south',
				height: 25
            })
            ]
        });

        addTab("Welcome","welcome.php",false,"crab-logo","welcomeTab" );

});